// 1.接口用来定义一个对象的类型
// 在定义类型的时候  属性和类型都是固定的
interface obj1Type{
name: string,
age: number
}

const obj1:obj1Type={
  name:"laowang",
  age:18
}

// 2.可选属性
interface obj2Type{
  name:string,
  age:number,
  sex?:any//可选属性
}

const obj2:obj2Type={
  name:"laoma",
  age:18,
  sex:"nan"//sex属性可能存在也可能不存在
}

// 3.对象中有数组
type obj3ScoreType=number[];

interface obj3Type{
  name:string,
  age:number,
  score:obj3ScoreType
}

const obj3={
  name:"laowang",
  age:18,
  score:[60,59,424]
}

// 4.对象中有对象
interface obj4OtherType{
  height:number,
  weight:number,
  girlFri:string[]
}

interface obj4Type{
  name:string,
  age:number,
  other:obj4OtherType
}

const obj4:obj4Type={
  name:"sisi",
  age:5,
  other:{
    height:120,
    weight:42,
    girlFri: ["lily", "lucy", "xiaoming"]        
  }
}

// 只读属性
interface obj5Type{
  name:string,
  // 只读属性
  readonly age:number
}

const obj5:obj5Type={
  name:"laowang",
  age:18
}

// obj5.age=19  只读属性 不能更改


//  接口的继承  运用:后端返回的数据很多是相同的,公共数据提取出来,对该数据继承
interface public{
  name:string,
  age:number
}

interface student extends public{
  height:number
}

const obj6:student={
  name:'sisi',
  age:5,
  height:120

}